#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<sys/types.h>
#include<unistd.h>
#include<sys/stat.h>
#include<fcntl.h>
#include<sys/mman.h>
#include<sys/wait.h>


int main(){
    int fd=open("test.txt",O_RDWR);
    if(fd<0)
    {
        perror("file open error:\n");
        return -1;

    }
    int len = lseek(fd,0,SEEK_END);
    void * addr = mmap(NULL,len,PROT_WRITE,MAP_SHARED,fd,0);
    if(addr==MAP_FAILED)
    {
        perror("mmap failed\n");
        return -1;
    }
    memcpy(addr,"hello pandas\n",strlen("hello pandaas\n"));
    return 0;

}